Skip to content

fix: move INITRD_MAP_BASE past LAPIC MMIO region - #94

Merged
danbugs merged 3 commits into
mainfrom
fix/initrd-apic-overlap
Jun 17, 2026
Merged

fix: move INITRD_MAP_BASE past LAPIC MMIO region#94
danbugs merged 3 commits into
mainfrom
fix/initrd-apic-overlap

Conversation

@danbugs

@danbugs danbugs commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Moves both INITRD_MAP_BASE constants from 0xC000_0000 (3 GiB) to 0xFEF0_0000 (just past the LAPIC MMIO page at 0xFEE0_0000)

When the initrd exceeds ~1 GiB (as it does in v0.9.0's python-agent-driver), the mapping at 0xC000_0000 spans the LAPIC MMIO region at 0xFEE0_0000. On kernels where KVM_CREATE_IRQCHIP reserves that range, KVM_SET_USER_MEMORY_REGION rejects the mapping with EEXIST.

The corresponding guest-side constant in Unikraft is updated in unikraft/unikraft#1850.

Fixes: microsoft/mxc#525

Test plan

  • Built the Unikraft kernel with the matching guest-side change via kraft-hyperlight build
  • Ran pydriver-run with the patched kernel + host against a ~1.07 GiB initrd
  • Confirmed via strace that the initrd slot maps at guest_phys_addr=0xfef00000 (past the LAPIC)
  • Guest boots and runs Python successfully

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Copilot AI review requested due to automatic review settings June 16, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the host-side initrd guest mapping base address to avoid overlapping the x86 LAPIC MMIO region, which can cause KVM_SET_USER_MEMORY_REGION to fail with EEXIST when mapping very large initrds.

Changes:

  • Move INITRD_MAP_BASE from 0xC000_0000 to 0xFEF0_0000 for zero-copy initrd mapping in Sandbox::evolve_mapped.
  • Move INITRD_MAP_BASE from 0xC000_0000 to 0xFEF0_0000 for initrd re-mapping when restoring from snapshot (from_snapshot_file_full initrd path).
  • Add an explanatory comment describing the LAPIC overlap failure mode and why the new address is chosen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread host/src/lib.rs
Comment on lines +2532 to 2535
const INITRD_MAP_BASE: u64 = 0xFEF0_0000;
if let Some(ref initrd_path) = initrd {
inner.map_file_cow(initrd_path, INITRD_MAP_BASE, Some("initrd"))?;
}
danbugs added 2 commits June 16, 2026 20:16
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux Benchmarks

Details
Benchmark suite Current: e06d5b6 Previous: f51e9da Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 90 ms 110 ms 0.82
density (per VM) 12 MB 11 MB 1.09
snapshot (disk) 656 MiB 656 MiB 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows Benchmarks

Details
Benchmark suite Current: e06d5b6 Previous: f51e9da Ratio
hello_world (median) 345 ms 294 ms 1.17
pandas (median) 978 ms 749 ms 1.31
density (per VM) 656 MB 656 MB 1
snapshot (disk) 664 MiB 664 MiB 1

This comment was automatically generated by workflow using github-action-benchmark.

@danbugs
danbugs merged commit 96021d9 into main Jun 17, 2026
182 of 267 checks passed
@danbugs
danbugs deleted the fix/initrd-apic-overlap branch June 17, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lxc-exec --setup-hyperlight fails

2 participants